package com.ssy.lingxi.pay.repository.assetAccount;

import com.ssy.lingxi.pay.entity.assetAccount.AccountTradeRecord;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 会员资金账户交易记录
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/7/21
 */
@Repository
public interface AccountTradeRecordRepository extends JpaRepository<AccountTradeRecord,Long>, JpaSpecificationExecutor<AccountTradeRecord> {
    Page<AccountTradeRecord> findByMemberAssetAccountIdOrderByTradeTimeDesc(Long memberAssetAccountId, Pageable page);

    AccountTradeRecord findFirstByTradeCode(String tradeCode);

    List<AccountTradeRecord> findByPayPlatformTradeCodeAndOperationAndStatus(String platformTradeCode, Integer operation, Integer status);

    List<AccountTradeRecord> findByTradeCodeAndPayPlatformTradeCodeAndOperationAndStatus(String tradeCode, String platformTradeCode, Integer operation, Integer status);

    Page<AccountTradeRecord> findByMemberAssetAccountIdAndOperationInAndTradeTimeGreaterThanEqualAndTradeTimeLessThanEqualOrderByTradeTimeDesc(Long memberAssetAccountId, List<Integer> operationList, Long startTime, Long endTime, Pageable page);
}
